package gameTheory;

import model.Route;
import graphs.Graph;

public class Profile {
	private static int nrOfPLayers = 1;
	
	private Strategy playerA;
	private Strategy others;
	
	public Profile(Strategy playerA, Strategy others, Graph g){
		this.playerA = playerA;
		this.others = others;
	}
	
	public Payoff getPayoff(Graph g){
		
		/*
		for (Route route : others.getRoutes())
			route.addPlayers(others.getProbability(route) * nrOfPLayers);
		for(Route route : playerA.getRoutes())
			route.addPlayers(playerA.getProbability(route));
		
		Payoff p = new Payoff();
		p.player = -getTravelTime(playerA);
		p.others = -getTravelTime(others);
		*/
		g.reset(1);
		for (Route route : others.getRoutes())
			route.addPlayers(others.getProbability(route) * nrOfPLayers);
		
		Payoff p = new Payoff();
		p.player = -getTravelTime(playerA);
		
		g.reset(nrOfPLayers);
		for(Route route : playerA.getRoutes())
			route.addPlayers(playerA.getProbability(route));
		
		p.others = -getTravelTime(others);
		
		return p;
	}
	
	private double getTravelTime(Strategy st) {
		double tt = 0;
		
		for(Route route : st.getRoutes()){
			tt += route.getTravelTime() * st.getProbability(route);
		}
		if(tt<0.1)
			System.out.println("BOE!!!");
		return tt;
	}

	public Strategy getPlayerA() {
		return playerA;
	}
	public Strategy getOthers() {
		return others;
	}
	
	public String toString(){
		return "playerProfile:" + playerA.toString() + " othersProfile:" + others.toString() + "\n";
	}
}
